package dk.au.cs.bdsi.sms.backend;

import dk.au.cs.bdsi.core.backend.AbstractListener;
import dk.au.cs.bdsi.core.backend.ListenerHandler;
import dk.au.cs.bdsi.core.backend.ListenerHandlerFactory;
import dk.au.cs.bdsi.sms.domain.Sms;
import dk.au.cs.bdsi.sms.repositories.SmsRepository;

/**
 * Listens for and processes all new {@link Sms} messages in the
 * current {@link SmsRepository}.
 */
public class SmsListener extends AbstractListener<Sms> {
	public SmsListener() {
		super(new HandlerFactory(), SmsRepository.current());
	}
	
	protected static class HandlerFactory implements ListenerHandlerFactory<Sms> {
		@Override
		public ListenerHandler<Sms> create() {
			return new SmsHandler();
		}
	}
	
	protected static class SmsHandler implements ListenerHandler<Sms> {
		@Override
		public void handle(Sms sms) {
			System.out.println("Trying to send " + sms);
			// TODO Implement sms sending mechanism
			// TODO Update sms status to fail, for testing purposes
		}
	}
}
